<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Account extends Model
{
    protected $table = 'dd_account';
    protected $primaryKey = 'id';
    public $timestamps = false;
    protected $guarded = array();
    
    /**
     * 收入支出
     * @return string
     */
    public function strStatus() {
        switch ($this->status) {
            case 1:
                return "收入";
            case 2:
                return "支出";
        } 
    }
    /**
     * 收支时间
     * @return type
     */
    public function strTime() {
        return date('Y-m-d H:i:s', $this->time);
    }
    /**
     * 后台操作时间
     * @return type
     */
    public function strPushTime() {
        return $this->pushtime ? date('Y-m-d H:i:s', $this->pushtime) : "";
    }
    /**
     * 提现申请状态
     */
    public function strPushStatus() {
        switch ($this->pushstatus) {
            case 1:
               return "<span class='text-info'>待审核</span>";
            case 2:
                return "<span class='text-success'>已打款</span>";
            case 3:
                return "<span class='text-danger'>未通过审核</span>";
        }
    }
    /**
     * 开户行
     */
    public function strBankInfo() {
        $user = User::find($this->uid);
        if(!$user->bankid || !$user->banktype || !$user->bankaddress || !$user->name) {
            return "<tr><td>请联系提现申请人，让他完善个人提现资料之后进行提现操作</td></tr>";
        } else {
         return "<tr><td>开卡人姓名</td><td>{$user->name}</td></tr><tr><td>银行卡号</td><td>{$user->bankid}</td></tr><tr><td>银行类型</td><td>{$user->strBankType()}</td></tr><tr><td>开户行</td><td>{$user->bankaddress}</td></tr>";   
        }
    }
    /**
     * 信息是否完善
     * @return string
     */
    public function isInfoFull() {
        $user = User::find($this->uid);
        if(!$user->bankid || !$user->banktype || !$user->bankaddress || !$user->name) {
            return false;
        }
        return true;
    }
}
